<?php
/**
 * 日志管理
 * @author zlian
 *
 */
namespace Userslog\Service;

class LogService {
	
	protected $actions = [
		'login' => '登录系统',
		'logout' => '登出系统',
		''
	];


	public function addLog($uid,$action,$info=''){
		$m = M('UsersLog');

		$ip = get_client_ip();//获取ip地址
		$client = $_SERVER['HTTP_USER_AGENT'];//获取客户端信息

		$info = $info ? $info : $this->actions[$action];

		$data = [
			'uid' => $uid,
			'action' => $action,
			'info' => $info,
			'ip' => $ip,
			'client' => $client,
			'create_time'=> Date('Y-m-d H:i:s'),
		];

		$m->add($data);

	}

}